package com.kingint.web.admin.serve.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.kingint.common.unitedresult.K;
import com.kingint.mbg.dto.CheckRoom.CheckRoomQueryParam;
import com.kingint.mbg.dto.department.DepartmentQueryParam;
import com.kingint.mbg.group.Insert;
import com.kingint.mbg.ser.entity.SerCheckRoom;
import com.kingint.web.admin.serve.service.SerCheckRoomService;
import com.kingint.web.portal.serve.service.CheckRoomService;
import com.kingint.web.portal.serve.service.SerWorkOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/sercheckRoom")
@Api(value = "SerCheckRoomController", description = "查房工单详情表")
@CrossOrigin
public class SerCheckRoomController {

    @Autowired
    public SerCheckRoomService checkRoomService;


    @ApiOperation(value = "添加查房工单详情表")
    @PostMapping("/create")
    public Object create(@Validated(Insert.class) @RequestBody SerCheckRoom serCheckRoom){
        return checkRoomService.addCheckRoomOder(serCheckRoom) ? K.ok().data("成功") : K.error().data("失败");
    }


    @ApiOperation(value = "根据编号查询查房工单详情表信息")
    @GetMapping("/{id}")
    public Object getItem(@PathVariable("id") Integer id){
        SerCheckRoom serCheckRoom = checkRoomService.getonebyid(id);
        return K.ok().data(serCheckRoom);
    }


    @ApiOperation(value = "根据查房工单详情表名称分页获取查房工单详情表列表")
    @GetMapping("/list")
    public Object getList(CheckRoomQueryParam serCheckRoom,
                          @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                          @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize){
        IPage<SerCheckRoom> serCheckRoomList = checkRoomService.getCheckRoomOder(serCheckRoom,pageNum,pageSize);
        return K.ok().data(serCheckRoomList);
    }
}
